<!DOCTYPE html>
<html lang="en">
<head>
    <title>Title</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta content="telephone=no,email=no" name="format-detection">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <script type="text/javascript" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/js/jquery-1.7.2.min.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script type="text/javascript" src="http://www.youyiku-yishu.cn/Apps/WebApp/View/default/js/jisuan.js"></script>

    <style type="text/css">
        .yuyin{
            width:2rem;
            height:1rem;
            background-color: #00a2d4;
            margin-bottom: 2rem;
        }
        .stop{
           width:2rem;
            height:1rem;
            background-color:#a4c400;
            margin-bottom: 2rem;
        }
        .change{
            width:2rem;
            height:1rem;
            background-color:#d93c37;
            margin-bottom: 2rem;
        }

    </style>

</head>
<body>
    <div class="yuyin" onclick="startRecord()">
        开始录制
    </div>
    <div class="stop" onclick="stopRecord()">停止录制</div>
    <input type="hidden" id="luyin">
    <div class="change" onclick="translateVoice()">转化</div>
</body>
<script>
    wx.config({
        debug: true,
        appId: '<?php echo $signPackage["appId"];?>',
        timestamp: <?php echo $signPackage["timestamp"];?>,
    nonceStr: '<?php echo $signPackage["nonceStr"];?>',
            signature: '<?php echo $signPackage["signature"];?>',
            jsApiList: [
        // 所有要调用的 API 都要加到这个列表中
        'startRecord','stopRecord','translateVoice'
    ]
    });
    function startRecord(){

        wx.startRecord();

    }
    function stopRecord(){

        wx.stopRecord({
            success: function (res) {
                var localId = res.localId;

                translateVoice(localId)
            }
        });
    }
    function translateVoice(localId){



        wx.translateVoice({
            localId: localId, // 需要识别的音频的本地Id，由录音相关接口获得
            isShowProgressTips: 1, // 默认为1，显示进度提示
            success: function (res) {
                alert(res.translateResult); // 语音识别的结果
            }
        });
    }

</script>
</html>